#ifndef __BIN_CRC_H
#define __BIN_CRC_H

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include <stdbool.h>
#include <stdint.h>
#include <signal.h>
#include <fcntl.h>
#include <errno.h>

#define INPUTFILE 	"/tmp/103_update.BIN"
#define BOARD_MAGIC_NUMBER 	0x10373011
#define BOARD_MODEL BOARD_MAGIC_NUMBER
#define FLASH_APP1_ADDR		0  		//未使用


typedef struct 
{
	unsigned int model;
	unsigned int version;
	unsigned int buildtime;
	unsigned int crc32val;
	unsigned int head_len;
	unsigned int data_len;
	unsigned int reserved1;
	unsigned int reserved2;
	unsigned int align[120];
}bin_head;
#define BIN_HEAD_LEN (sizeof(bin_head))

#define max_pack_len 2048
typedef struct 
{
	unsigned int model;
	unsigned int version;
	unsigned int buildtime;
	unsigned int crc32val;
	unsigned int file_len;
	unsigned int data_len;
	unsigned int region_idx;
	unsigned int flash_bak_base;
	unsigned int flash_data[max_pack_len/4];
}updata_bak_region;
#define BAK_REGION_LEN (sizeof(updata_bak_region))
#define BAK_REGION_HEAD_LEN (4*8)


#define APP_RUN_ADDR (FLASH_APP1_ADDR+BIN_HEAD_LEN)  	//链接地址（APP起始地址）






#endif








